package com.itheima.dao.impl;

import com.itheima.dao.IManagerDao;
import com.itheima.domain.Manager;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class ManagerDaoImpl implements IManagerDao {

    private static ArrayList<Manager> list = new ArrayList<>();

    static {
        try {
            BufferedReader reader = new BufferedReader(new FileReader("kaoshi\\manager.txt"));
            String s;
            while ((s = reader.readLine()) != null) {
                String[] managerInfo = s.split(",");
                Manager manager = new Manager(managerInfo[0], managerInfo[1], managerInfo[2], managerInfo[3]);
                list.add(manager);
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }


    }


    @Override
    public ArrayList<Manager> findAll() {

        return list;
    }
}
